cc.Class({
    extends: cc.Component,

    properties: {
        awa:{
            default:[],
            type:cc.Node
        }
    },

    // use this for initialization
    onLoad: function () {
        this.end = 160;//speed 终止速度
    },

    show:function(){
    	this.node.active = true;
    },

    hide:function(){
    	this.node.active = false;
    },


    draw:function(e,num){
        this.runLottery(num,function(){

        })
    },

    runLottery : function(num, cb){
        this.round = 0;
        this.speed = 30;
        this.counter = 0.2;
        this.zhuanquan(num, cb);
    },
    
    zhuanquan : function(num, cb){
        console.log(this.speed);
        for (var i in this.awa) {
            var grid = this.awa[i];

            if(i == this.round){
                grid.active = true;
            }else{
                grid.active = false;
            }
        }
        if(this.speed >= this.end && this.round == num){
            cb();
            return;
        }

        if(this.round >= this.awa.length){
            this.round = 0;
            this.counter += 0.6;
        }else{
            this.round++;
        }

        this.speed = this.counter * this.counter * 30 + 30;
        let self = this;
        setTimeout(function(){
            self.zhuanquan(num, cb);
        }, this.speed);
    },

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});
